/**
 * 存储 localStorage
 */

export const storageSet = (key, value) => {
  if (typeof value === 'object' && value !== null) {
    return localStorage.setItem(key, JSON.stringify(value))
  }
  localStorage.setItem(key, value)
}

/**
 * 获取缓存里面的值
 */

export const storageGet = key => {
  const obj = localStorage.getItem(key)
  try {
    return JSON.parse(obj)
  } catch (error) {
    return obj
  }
}
/**
 * 清空缓存里面的值
 */
export const storageClear = key => {
  localStorage.removeItem(key)
}
